package com.guigu.tankai.controller;

import com.github.pagehelper.PageInfo;
import com.guigu.tankai.pojo.User;
import com.guigu.tankai.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("User")
public class UserController {

    @Autowired
    UserService userService;

    @RequestMapping("login") // 登录验证
    public User login(@RequestBody User user){
       return userService.login(user);
    }

    @RequestMapping("cha") // 查询账户是否存在
    public User cha(User user){
        return userService.login(user);
    }

    @RequestMapping("tkpageUser")
    public PageInfo<User> pageUser(Integer page, Integer num, String clm) {
        User user = new User();
                user.setFullname(clm);
                user.setTelephone(clm);
        PageInfo<User> byUser = userService.findByUser(page, num, user);
        return byUser;
    }
    @RequestMapping("tkdelUser")
    public int deleteByPrimaryKey(Integer id) {
        return userService.deleteByPrimaryKey(id);
    }

    @RequestMapping("tkaddUser")
    public int insertSelective(@RequestBody User record) {
        return userService.insertSelective(record);
    }

    @RequestMapping("tkselUser")
    public User selectByPrimaryKey(Integer id) {
        return userService.selectByPrimaryKey(id);
    }

    @RequestMapping("tkupdeUser")
    public int updateByPrimaryKey(@RequestBody User record) {
        return userService.updateByPrimaryKey(record);
    }
}
